<template>
    <div>
        <article-item :data="articles"/>
        <page-split :data="pageData"/>
    </div>
</template>

<script>
	import ArticleItem from '@/components/pagecomponents/ArticleItem';
	import PageSplit from '@/components/pagecomponents/PageSplit';
	export default {
		name: "index",
		components:{
			ArticleItem,
			PageSplit
		},
		async asyncData({app}){
			let page = 1;
			let result = await app.$getWebPage({page:1,num:10});
			let totalPage = Math.ceil(result.data.totals / 10);
			if(page > totalPage){
				redirect('/error')
			}
			return {
				articles:result.data.articleList,
				pageData:{
					baseUrl:'/webpage',
					page:1,
					totals:result.data.totals,
					totalPage
				}
			}
		},
	}
</script>

<style scoped>

</style>